/**
 * @file       Rect.h
 * @brief      CRect
 * @author     Huabo Zheng
 * @date       Jan 12, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#ifndef RECT_H_
#define RECT_H_

#include "Object.h"
#include "lcd/LCDFactory.h"

namespace NS_LCD_AFW
{

class CPoint;

/**
 *@class  CRect
 *@brief  CRect
 */
class CRect: public CObject
{
public:

	/**
	 *@brief Constructor
	 *@attention If no arguments are given, CRect are initialized as (-1,-1,-1,-1).
	 *@see CRect(int left, int top, int width, int hight)
	 *@see CRect(const CPoint &leftTop, const CPoint &rightBottom)
	 */
	CRect();

	/**
	*@brief Constructor with init params
	*@param[in] left Specifies the left position of CRect.
	*@param[in] top Specifies the top of CRect.
	*@param[in] width Specifies the width of CRect.
	*@param[in] hight  Specifies the height of CRect.
	*@exception none
	*@retval    none
	*@return    none
	*@note      none
	*@attention
	*@see CRect()
	*@see CRect(const CPoint &leftTop, const CPoint &rightBottom)
	*/
	CRect(int left, int top, int width, int hight);

	/**
	*@brief Constructor with init params
	*@param[in] leftTop Specifies the top-left position of CRect.
	*@param[in] rightBottom Specifies the bottom-right position of CRect.
	*@exception none
	*@retval    none
	*@return    none
	*@note      none
	*@attention
	*@see CRect()
	*@see CRect(int left, int top, int width, int hight)
	*/
	CRect(const CPoint &leftTop, const CPoint &rightBottom);

	virtual ~CRect();

public:

	/**
	 *@brief  Get the value of the height member of CRect
	 *@details Get the value of the height member of CRect
	 *@exception none
	 *@retval    int
	 *@return    The value of the height member of CRect
	 *@note
	 *@attention
	 *@see
	*/
	int getHight() const;

	/**
	 *@brief  Get the value of the width member of CRect
	 *@details Get the value of the width member of CRect
	 *@exception none
	 *@retval    int
	 *@return    The value of the width member of CRect
	 *@note
	 *@attention
	 *@see
	*/
	int getWidth() const;

	/**
	 *@brief  Get the  left position of CRect.
	 *@details Get the  left position of CRect.
	 *@exception none
	 *@retval    int
	 *@return    The   left position of CRect.
	 *@note
	 *@attention
	 *@see
	*/
	int getLeft() const;

	/**
	 *@brief   Get the  top position of CRect.
	 *@details Get the  top position of CRect.
	 *@exception none
	 *@retval    int
	 *@return    The   top position of CRect.
	 *@note
	 *@attention
	 *@see
	*/
	int getTop() const;


	/**
	 *@brief  Set the value of the height member of CRect
	 *@details Set the value of the height member of CRect
	 *@param[in]  height The new  value of the height member of CRect
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setHight(int hight);

	/**
	 *@brief  Set the value of the width member of CRect
	 *@details Set the value of the width member of CRect
	 *@param[in]  width The new  value of the width member of CRect
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setWidth(int width);

	/**
	 *@brief  Set the  left position of CRect.
	 *@details Set the  left position of CRect.
	 *@param[in]  left The new  value of the left position of CRect.
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setLeft(int left);

	/**
	 *@brief  Set the  top position of CRect.
	 *@details Set the  top position of CRect.
	 *@param[in]  top   The new  value of the top position of CRect.
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setTop(int top);

	/**
	 *@brief   Returns the top-left point of CRect.
	 *@details Returns the top-left point of CRect.
	 *@exception none
	 *@retval    CPoint
	 *@return    The top-left point of CRect.
	 *@note
	 *@attention
	 *@see
	*/
	CPoint getLeftTop() const;

	/**
	 *@brief   Returns the bottom-right point of CRect.
	 *@details Returns the bottom-right point of CRect.
	 *@exception none
	 *@retval    CPoint
	 *@return    The bottom-right point of CRect.
	 *@note
	 *@attention
	 *@see
	*/
	CPoint getRightBottom() const;

	/**
	 *@brief   Returns the center point of CRect.
	 *@details Returns the center point of CRect.
	 *@exception none
	 *@retval    CPoint
	 *@return    The center point of CRect.
	 *@note
	 *@attention
	 *@see
	*/
	CPoint getCenterPoint() const;


	/**
	 *@brief   Determines whether CRect is empty.
	 *@details Determines whether CRect is empty. CRect is empty if the width and/or height are 0.
	 *@exception none
	 *@retval    bool
	 *@return    true if CRect is empty; false if CRect is not empty.
	 *@note
	 *@attention
	 *@see
	*/
	bool isRectEmpty() const;

	/**
	 *@brief   Determines whether the top, left, bottom, and right values of CRect are all less then 0
	 *@details  Determines whether the top, left, bottom, and right values of CRect are all less then 0
	 *@exception none
	 *@retval    bool
	 *@return    true if CRect is NULL; false if CRect is not NULL.
	 *@note
	 *@attention
	 *@see
	*/
	bool isRectNull() const;


	/**
	 *@brief   Determines whether the specified point lies within CRect
	 *@details  Determines whether the specified point lies within CRect
	 *@param[in] pt A CPoint object
	 *@exception none
	 *@retval    bool
	 *@return    true if the point lies within CRect; otherwise false.
	 *@note
	 *@attention
	 *@see
	*/
	bool isPointInRect(const CPoint &pt) const;

	/**
	 *@brief   Determines whether CRect is equal to the given rectangle.
	 *@details  Determines whether CRect is equal to the given rectangle.
	 *@param[in] other Another CRect object
	 *@exception none
	 *@retval    bool
	 *@return    true if the two rectangles have the same top, left, bottom, and right values; otherwise false.
	 *@note
	 *@attention
	 *@see
	*/
	bool isEqualWith(const CRect &other) const;


	/**
	 *@brief   Moves CRect by the specified offsets.
	 *@details  Moves CRect by the specified offsets.
	 *@param[in] offsetX Specifies the amount to move left or right. It must be negative to move left.
	 *@param[in] offsetY Specifies the amount to move up or down. It must be negative to move up.
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void offsetRect(int offsetX, int offsetY);

	/**
	 *@brief   Determines whether the specified Rect is valid
	 *@details  Determines whether the specified Rect is valid,a rect is valid while all of its width and height greater then zero.
	 *@exception none
	 *@retval    bool
	 *@return    true if the  rectangle's width and height greater then zero ; otherwise false.
	 *@note
	 *@attention
	 *@see
	*/
	bool isValidRect() const;

	/**
	 *@brief   Determines whether CRect is equal to a rectangle.
	 *@details Determines whether rect is equal to CRect by comparing the coordinates of their upper-left and lower-right corners.
	 *@param[in] other Refers to a source rectangle
	 *@exception none
	 *@retval    bool
	 *@return    true if equal; otherwise false.
	 *@note
	 *@attention
	 *@see
	*/
	bool operator==(const CRect &other) const;

	/**
	 *@brief   Determines whether CRect is inequal to a rectangle.
	 *@details Determines whether rect is inequal to CRect by comparing the coordinates of their upper-left and lower-right corners.
	 *@param[in] other Refers to a source rectangle
	 *@exception none
	 *@retval    bool
	 *@return    true if equal; otherwise false.
	 *@note
	 *@attention
	 *@see
	*/
	bool operator!=(const CRect &other) const;
	//bool operator>(const CRect &other) const;

private:

	/**  the  left position of CRect.*/
	int m_nLeft;
	/** the  top position of CRect.*/
	int m_nTop;
	/** the  width position of CRect.*/
	int m_nWidth;
	/** the  height position of CRect.*/
	int m_nHight;
};
/**
*@brief The default width of display object
*/
#define LCD_WIDTH         (AfwGetLCDFactory()->createDisplayDevice(0)->getColumnSize())
/**
*@brief The default height of display object
*/
#define LCD_HEIGHT        (AfwGetLCDFactory()->createDisplayDevice(0)->getRowSize())
/**
*@brief The default rectangle of CPanel object
*/
#define DEFAULT_RECT   (CRect(0,0,LCD_WIDTH,LCD_HEIGHT))
} /* namespace NS_LCD_AFW */
#endif /* RECT_H_ */
